package com.ydd.mapper;

import com.github.pagehelper.Page;
import com.ydd.dto.SysUserDTO;
import com.ydd.entity.SysUser;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author hgz
 * @since 2023-05-30
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    @Select("select count(*) from sys_user where role_id = #{adminId}")
    Integer getCountAdmin(String adminId);

    @Select("select * from sys_user where login_name = #{loginName}")
    SysUser getByUsername(String loginName);

    @Select("select * from sys_user where id = #{id}")
    SysUser findById(String Id);


    /**
     * 用户列表分页查询
     *
     * @param sysUserDTO
     * @return
     */
    Page<SysUser> pageQuery(SysUserDTO sysUserDTO);


    /**
     * 管理员添加
     *
     * @param sysUser
     */
    void addUser(SysUser sysUser);


    @Delete("delete from sys_user where id = #{id}")
    void SysUserdelect(String id);


    /**
     * 管理员详情
     *
     * @param id
     * @return
     */
    @Select(" select * from sys_user where id = #{id}")
    SysUser UserRowInfo(String id);


    /**
     *管理员修改
     * @param sysUser
     */
    void userUpdate(SysUser sysUser);
}
